<!--   
Persistent Digital Archives and Library System (PeDALS) 
(c) 2008 - All Rights Reserved
//-->
<?php include 'includes/config.php'; 
$term = urldecode(@$_GET["acq"]);	
if ($term == "") {
echo "Acquisition not found.  You did not select a valid acquisition for viewing.";
die;
}
$params = array(&$term);			  
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Persistent Digital Archives and Library System" />
<title>PeDALS Web Administration</title>
<link rel="shortcut icon" href="images/favicon.ico" />
<link href="includes/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include 'includes\header.php'; ?>
<div id="breadcrumb-container">
  <div id="breadcrumb"><a href="index.php" title="Home page">Home</a> / <a href="acqSummary.php" title="Acquisitions">Acquisitions</a> / Acquisition Detail</div>
  <div id="breadcrumb-side"><form name="search" action="search.php"><input type="text" name="q" width="50"/><input type="submit" value="Go" /></form><a href="advSearch.php" title="Advanced Search" alt="Advanced Search">Advanced Search</a>
  </div>
  <div class="clear"></div>
</div>
<!-- 

  CONTENT

  -->
<div id="content-container">
  <!-- 
	
	SIDE COLUMN
	
	-->
  <div id="content-side">
    <ul class="link-list-vertical">
      <li><a href="acqSummary.php" title="View a list of all acquisitions in PeDALS.">List Acquisitions</a></li>
      <li><a href="acqNew.php" title="Add a new acquisition to PeDALS.">Add Acquisition</a></li>
    </ul>
  </div>
  <!-- 
	MAIN COLUMN
	-->
  <div id="content"><a name="maincontent" id="maincontent"></a>
  <?php
  $tsql = "SELECT TOP 1 Provenance.ProvenanceName, Series.SeriesTitle, SeriesAcquisition.SeriesAcquisitionId, SeriesAcquisition.SeriesId, CONVERT(VARCHAR, SeriesAcquisition.SeriesAcquisitionReceivedDate,101) AS SeriesAcquisitionReceivedDate, CONVERT(VARCHAR, SeriesAcquisition.SeriesAcquisitionIngestDate, 101) AS SeriesAcquisitionIngestDate, SeriesAcquisition.SeriesAcquisitionReadyToIngest, SeriesAcquisition.SeriesAcquisitionIngested, SeriesAcquisition.SeriesAcquisitionAccessionNumber, SeriesAcquisition.SeriesAcquisitionTransferAuthority, SeriesAcquisition.SeriesAcquisitionSource, SeriesAcquisition.SeriesAcquisitionDirectory, CONVERT(VARCHAR, SeriesAcquisition.CreatedDate, 101) AS CreatedDate, SeriesAcquisition.CreatedBy, CONVERT(VARCHAR, SeriesAcquisition.ModifiedDate, 101) AS ModifiedDate, SeriesAcquisition.ModifiedBy, SeriesAcquisition.SuperPackageId, Provenance.ProvenanceId
			FROM Provenance INNER JOIN Series ON Provenance.ProvenanceId = Series.ProvenanceId INNER JOIN
                    SeriesAcquisition ON Series.SeriesId = SeriesAcquisition.SeriesId
			WHERE SeriesAcquisition.SeriesAcquisitionId = (?)";
	$getData = sqlsrv_prepare( $conn, $tsql, $params);
 	if( $getData === false ) {
		 echo "Error in preparing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	/* Execute the statement. Display any errors that occur. */
	if( sqlsrv_execute( $getData))
	{   
	/*echo "Statement executed.\n";*/
	}
	else
	{
		 echo "Error in executing statement.\n";
		 die( print_r( sqlsrv_errors(), true));
	}
	
	$rowCount = 0;
 	while (sqlsrv_fetch( $getData ))
	{	
		$provName = sqlsrv_get_field($getData, 0);
		$seriestitle = sqlsrv_get_field($getData, 1);
		$id = sqlsrv_get_field($getData, 2);
		$serid = sqlsrv_get_field($getData, 3);
		$recdate = sqlsrv_get_field($getData, 4);
		$ingestdate = sqlsrv_get_field($getData, 5);
		$readytoingest = sqlsrv_get_field($getData, 6);
		$ingested = sqlsrv_get_field($getData, 7);
		$accessionno = sqlsrv_get_field($getData, 8);
		$transfer = sqlsrv_get_field($getData, 9);
		$source = sqlsrv_get_field($getData, 10);
		$directory = sqlsrv_get_field($getData, 11);
		$createdon = sqlsrv_get_field($getData, 12);
		$createdby = sqlsrv_get_field($getData, 13);
		$modifiedon = sqlsrv_get_field($getData, 14);
		$modifiedby = sqlsrv_get_field($getData, 15);
		$superpackageid = sqlsrv_get_field($getData, 16);
		$provid = sqlsrv_get_field($getData, 17);		
				$rowCount++;
	}
	
	/* acq id in query string is wrong */
	if( $rowCount == 0 ) { 
	echo "Acquisition not found.  You did not select a valid acquisition for viewing.<br/><br/><br/><br/>";
	die;
    	}	

 ?>    
    <h1>Acquisition submitted on <?php echo $ingestdate; ?></h1>
    <p><strong>Provenance:</strong> <?php echo $provName; ?><br/>  
    <strong>Series:</strong> <?php echo $seriestitle; ?></p>   
    <p><strong>Ingest Status:</strong> 
	<?php 
	switch ($readytoingest) {
    case 0:
        echo "Waiting for submission.<br/>";
        break;
    case 1:
        echo "Accepted.  BizTalk creating superpackage.<br/>";
        break;
    case 2:
        echo "Rejected.  BizTalk removing records.<br/>";
        break;
    case 3:
        echo "Rejected at least once. Waiting for resubmission.<br/>";
		echo "<a title=\"Review items\"";
		echo " alt=\"Review items\"";
		echo " href=itemSummary.php?acq=".$id."";
		echo ">Review items</a><br/>";		
        break;		
    case 4:
        echo "Ready for ingest by LOCKSS. Superpackage has been created.<br/>";
		echo "<strong>Superpackage ID:</strong> ".$superpackageid."";
		echo "<br/><strong>Ingested into LOCKSS:</strong> ".$ingested."";		
        break;
    case 5:
        echo "Ready for review.<br/>";
		echo "<a title=\"Review items\"";
		echo " alt=\"Review items\"";
		echo " href=itemSummary.php?acq=".$id."";
		echo ">Review items</a><br/>";		
        break;
    case 9:
        echo "BizTalk processing submitted records.<br/>";
        break;		
}?></p>
    <p><strong>Accession Number:</strong> <?php echo $accessionno; ?></p>        
    <p><strong>Date Received by Agency:</strong> <?php echo $recdate; ?><br/>    
    <strong>Date Submitted to PeDALS for Processing:</strong> <?php echo $ingestdate; ?></p>    
    <p><strong>Transfer Authority:</strong> <?php echo $transfer; ?></p>
    <p><strong>Source:</strong> <?php echo $source; ?></p>
    
    <p><strong>General Note</strong>:
		<?php 
        $tsqlGN = "SELECT SeriesAcquisitionGeneralNote FROM SeriesAcquisition WHERE SeriesAcquisitionId = (?)";
        $stmt = sqlsrv_query( $conn, $tsqlGN, $params);
        
        while ($rr=sqlsrv_fetch_array($stmt, SQLSRV_FETCH_BOTH)){
            echo $rr[0];
        }
         ?></p> 
 
    <p><strong>File Directory:</strong> <?php echo $directory; ?></p>  
    <p><strong>NZME Input Values:</strong><br/>ID (ProvenanceId) = <?php echo $provid; ?><br/>
    Name (SeriesId) = <?php echo $serid; ?><br/>
    Group ID (SeriesAcquisitionId) = <?php echo $id; ?></p>

<p><strong>Actions</strong>:<br/>
<?php 
	sqlsrv_free_stmt( $getData );	
	sqlsrv_close( $conn);
		echo "<a title=\"Edit\"";
		echo " alt=\"Edit\"";
		echo " href=acqEdit.php?acq=".$id."";
		echo ">Edit this information</a><br/>";		
		?>
        <?php
		echo "<a title=\"View items\"";
		echo " alt=\"View items\"";
		echo " href=itemSummary.php?acq=".$id."";
		echo ">View items</a><br/>";		
		?>        
        <?php
		echo "<a title=\"Add acquisition\"";
		echo " alt=\"Add acquisition\"";
		echo " href=acqNew.php?ser=".$serid."";
		echo ">Add acquisition</a><br/>";		
		?>
        <?php
		echo "<a title=\"View provenance detail\"";
		echo " alt=\"View provenance detail\"";
		echo " href=provDetail.php?prov=".$provid."";
		echo ">View provenance detail</a><br/>";		
		?>  
        <?php
		echo "<a title=\"View series detail\"";
		echo " alt=\"View series detail\"";
		echo " href=serDetail.php?ser=".$serid."";
		echo ">View series detail</a><br/>";		
		?>        
        </p>

      <p><strong>Properties</strong>:<br/>
Ingest Status: 
	<?php 
	switch ($readytoingest) {
    case 0:
        echo "Ready for review.<br/>";
        break;
    case 1:
        echo "Accepted.  BizTalk processing records.<br/>";
        break;
    case 2:
        echo "Rejected.  BizTalk removing records.<br/>";
        break;
    case 3:
        echo "Rejected at least once.  Ready for review.<br/>";
        break;		
    case 4:
        echo "Ready for ingest by LOCKSS.  Superpackage has been created.<br/>";
        break;		
}?>
      Created by <?php echo $createdby; ?> on <?php echo $createdon; ?><br/>
      <?php
	  if ($modifiedby != "") {
      	echo "Modified by ".$modifiedby." on ".$modifiedon;
	  }
	?>
     
<?php include 'includes\footer.php'; ?>
  </div>
</div>
</body>
</html>
